home *** CD-ROM | disk | FTP | other *** search
- #include <time.h>
- #include <string.h>
- #include <stdio.h>
- #include <assert.h>
-
- void xtime();
-
- int main()
- {
- xtime();
- }
-
- void xtime()
- {
- time_t t;
- struct tm *pm, m;
-
- printf("==> starting xtime <==\n");
- m.tm_sec=56; m.tm_min=48; m.tm_hour=21;
- m.tm_mday=12; m.tm_mon=9; m.tm_year=85;
-
- t=mktime(&m);
- assert(m.tm_wday==6); assert(m.tm_yday==284);
-
- assert(t==182468936L);
- assert(difftime(time(NULL),t) > 0.0); // --- running this after 1985
-
- pm=localtime(&t);
- assert(pm->tm_year==85); assert(pm->tm_mon==9); assert(pm->tm_mday==12);
- assert(pm->tm_hour==21); assert(pm->tm_min==48); assert(pm->tm_sec==56);
- assert(pm->tm_wday==6); assert(pm->tm_yday==284);
- assert(strcmp(asctime(pm),"Sat Oct 12 21:48:56 1985\n")==0);
-
- t=time(NULL); printf("Today is:%sPlease wait.....",ctime(&t));
- sleep(5L);
- t=time(NULL); printf("\nToday+5s:%s",ctime(&t));
-
- printf("passed time tests...\n");
- printf("==> finished xtime <==\n");
-
- return;
- }
-